export const delFormNullParam = (params) => {
  const newParams = {}
  for (const key in params) {
    const val = params[key]
    if (val !== null && val !== '') {
      newParams[key] = val
    }
  }
  return newParams
}
export const routerParams = (vm) => {
  const params = {}
  if (vm.$route.fullPath.includes('?')) {
    const paramStrs = vm.$route.fullPath.split('?')[1].split('&')
    paramStrs.map((item) => {
      const split = item.split('=')
      params[split[0]] = decodeURIComponent(split[1])
    })
  }
  return params
}
export const cpKeys = (target, source, ...keys) => {
  keys.map((key) => {
    target[key] = source[key]
  })
  return target
}
export const elRowsGetByName = (elRows, name) => {
  for (let i = 0; i < elRows.length; i++) {
    for (let j = 0; j < elRows[i].elCols.length; j++) {
      if (elRows[i].elCols[j].elFormItem.prop === name) {
        return elRows[i].elCols[j]
      }
    }
  }
}

export const formItemsGetByName = (formItems, name) => {
  for (let i = 0; i < formItems.length; i++) {
    if (formItems[i].elFormItem.prop === name) {
      return formItems[i]
    }
  }
}
